package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.service.ScgwcService;
import com.zr.service.TjddService;
import com.zr.serviceimp.ScgwcServiceimpl;
import com.zr.serviceimp.TjddServiceImpl;

/**
 * 提交订单
 * @author 柏小毛
 *
 */
public class TjddController extends HttpServlet{
	ScgwcService ss=new ScgwcServiceimpl();
	TjddService ts=new TjddServiceImpl();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	// TODO Auto-generated method stub
	doPost(req, resp);
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		String a=(String)req.getParameter("gid");
		String b=(String)req.getParameter("nub");
		int nub=Integer.parseInt(b);
		int gid=Integer.parseInt(a);
		if(nub>ts.sycpsl(gid)){
			PrintWriter pw=resp.getWriter();
			pw.write("1");
			pw.flush();
			pw.close();

		}else{
			PrintWriter pw=resp.getWriter();
			pw.write("0");
			pw.flush();
			pw.close();

		ts.tjddbygid(gid);
		ts.jqymaisl(gid);
		ss.scgwcByGid(gid);
		
		}
}
	}

